﻿using Glue.Internals;
using Xunit;

namespace GlueTests
{
    namespace NullableRuntimeTypeTest
    {
        public class When_creating_valid_NullableRuntimeType
        {
            private readonly NullableRuntimeType nullable;

            
            public When_creating_valid_NullableRuntimeType()
            {
                nullable = new NullableRuntimeType(typeof(int?));
            }

            [Fact]
            public void Should_report_underlying_type()
            {
                Assert.Equal(typeof(int),nullable.GetUnderlyingType());
            }

            [Fact]
            public void Should_return_default_value()
            {
                Assert.Equal(0,nullable.GetDefaultValue());
            }

        }

        public class When_asking_if_type_is_nullable
        {
            [Fact]
            public void Should_be_true_if_type_is_nullable()
            {
                Assert.True(NullableRuntimeType.IsNullable(typeof(bool?)));
            }

            [Fact]
            public void Should_be_false_if_type_is_not_nullable()
            {
                Assert.False(NullableRuntimeType.IsNullable(typeof(double)));
            }
        }
    }
}
